package edu.ptit.jad.configuration;

import java.io.FileReader;
import java.io.IOException;
import java.io.Reader;
import java.util.Properties;

public class Configuration {

	private static final String CONFIG_FILE = "conf/app.properties";
	private static Configuration config = null;

	private String dirTrains;
	private String dirPreprocess;
	private String dirOut;

	public Configuration() {
		Reader reader = null;
		try {
			reader = new FileReader(CONFIG_FILE);
			Properties prop = new Properties();
			prop.load(reader);

			setDirTrains(prop.getProperty("jad.dir.trains"));
			setDirPreprocess(prop.getProperty("jad.dir.preprocess"));
			setDirOut(prop.getProperty("jad.dir.out"));

		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		} finally {
			if (reader != null) {
				try {
					reader.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		}
	}

	public static Configuration getInstance() {

		if (config == null) {
			config = new Configuration();
		}

		return config;
	}

	String getDirTrains() {
		return dirTrains;
	}

	void setDirTrains(String dirTrains) {
		this.dirTrains = dirTrains;
	}

	public String getDirPreprocess() {
		return dirPreprocess;
	}

	void setDirPreprocess(String dirPreprocess) {
		this.dirPreprocess = dirPreprocess;
	}

	public String getDirOut() {
		return dirOut;
	}

	void setDirOut(String dirOut) {
		this.dirOut = dirOut;
	}

}
